<?php
	if($id == FALSE){
		$urutan		= set_value("urutan");
		$pertanyaan	= set_value("pertanyaan");
		// $bobot		= set_value("bobot");
		$jawaban	= set_value("jawaban");
		$jawaban2	= set_value("jawaban2");
		$jawaban3	= set_value("jawaban3");
		$jawaban4	= set_value("jawaban4");
		$status		= set_value("status");
		$tampak		= set_value("tampak");
	} else {
		$urutan		=(set_value("urutan") == "") ? ($value["URUTAN"]) : (set_value("urutan"));
		$pertanyaan	=(set_value("pertanyaan") == "") ? ($value["PERTANYAAN"]) : (set_value("pertanyaan"));
		// $bobot		=(set_value("bobot") == "") ? ($value["BOBOT"]) : (set_value("bobot"));
		$jawaban	=(set_value("jawaban") == "") ? ($value["JAWABAN"]) : (set_value("jawaban"));
		$jawaban2	=(set_value("jawaban2") == "") ? ($value["JAWABAN2"]) : (set_value("jawaban2"));
		$jawaban3	=(set_value("jawaban3") == "") ? ($value["JAWABAN3"]) : (set_value("jawaban3"));
		$jawaban4	=(set_value("jawaban4") == "") ? ($value["JAWABAN4"]) : (set_value("jawaban4"));
		$status		=(set_value("status") == "") ? ($value["STATUS"]) : (set_value("status"));
		$tampak		=(set_value("tampak") == "") ? ($value["TAMPAK"]) : (set_value("tampak"));
	}
?>

<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>
					<span>Form Master Pertanyaan</span>
				</h4>
			</div>
			<div class="panel-body">
				<form class="form-horizontal" action="" method="post" role="form">
					<div class="form-group hidden">
						<label class="col-lg-3 control-label" for="normalInput">ID Pertanyaan</label>
						<div class="col-lg-3">
							<input type="text" name="idpertanyaan" value="<?php echo $id; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="normalInput">Urutan</label>
						<div class="col-lg-3">
							<input type="text" name="urutan" value="<?php echo $urutan; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="textareas">Pertanyaan</label>
						<div class="col-lg-3">
							<textarea id="textarea1" rows="3" name="pertanyaan" class="form-control elastic"><?php echo $pertanyaan; ?></textarea>
						</div>
					</div><!-- End .form-group  -->
					<!--<div class="form-group">
						<label class="col-lg-3 control-label" for="normalInput">Bobot</label>
						<div class="col-lg-3">
							<input type="text" name="bobot" value="<?//php echo $bobot; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="normalInput">Jawaban</label>
						<div class="col-lg-3" id="jawaban">
							<input type="text" name="jawaban" value="<?php echo $jawaban; ?>" class="form-control">
							<?php echo ($jawaban2 == null) ? ("") : ("<input type=\"text\" name=\"jawaban2\" value=\"" . $jawaban2 . "\" class=\"form-control\">")?>
							<?php echo ($jawaban3 == null) ? ("") : ("<input type=\"text\" name=\"jawaban3\" value=\"" . $jawaban3 . "\" class=\"form-control\">")?>
							<?php echo ($jawaban4 == null) ? ("") : ("<input type=\"text\" name=\"jawaban4\" value=\"" . $jawaban4 . "\" class=\"form-control\">")?>
						</div>
						<button type="button" class="btn btn-default" onClick="tambah('jawaban')"><span class="icon16 icomoon-icon-plus-circle">&nbsp;Tambah</span></button>
					</div><!-- End .form-group  -->
					<?php
					$no	= 0;
					foreach($master_ijin as $row){
					$no++;
					?>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="checkboxes"><?php echo ($no == 1) ? ("Jenis Ijin") : (""); ?></label>
						<div class="col-lg-9">
							<label class="checkbox-inline">
								<input type="checkbox" id="inlineCheckbox1" value="<?php echo $row["ID_IJIN"]; ?>" <?php echo ($id == FALSE) ? ("checked") : (($row["ID_IJIN2"] == null) ? ("") : ("checked")); ?> name="<?php echo $row["ID_IJIN"]; ?>"> <?php echo $row["NAMA_IJIN"]; ?>
							</label>
						</div>
					</div><!-- End .form-group  -->
					<?php
					}
					?>
					<?php if($id==FALSE) { ?>
						<div class="form-group">
							<label class="col-lg-3 control-label" for="select">Status</label>
							<div class="col-lg-3">
								<select name="status" class="form-control">
									<option value="">--Pilih Status--</option>
									<option <?php echo ($status == null) ? ("") : (($status == 1) ? ("selected") : ("")); ?> value="1" selected>Aktif</option>
									<option <?php echo ($status == null) ? ("") : (($status == 0) ? ("selected") : ("")); ?> value="0">Tidak Aktif</option>
								</select>
							</div>
						</div><!-- End .form-group  -->
					<?php } else { ?>
						<div class="form-group">
							<label class="col-lg-3 control-label" for="select">Status</label>
							<div class="col-lg-3">
								<select name="status" class="form-control">
									<option value="">--Pilih Status--</option>
									<option <?php echo ($status == null) ? ("") : (($status == 1) ? ("selected") : ("")); ?> value="1">Aktif</option>
									<option <?php echo ($status == null) ? ("") : (($status == 0) ? ("selected") : ("")); ?> value="0">Tidak Aktif</option>
								</select>
							</div>
						</div><!-- End .form-group  -->
					<?php } ?>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="select">Tampak</label>
						<div class="col-lg-3">
							<select name="tampak" class="form-control">
								<option value="">--Pilih Status Tampak--</option>
								<option <?php echo ($tampak == null) ? ("") : (($tampak == 1) ? ("selected") : ("")); ?> value="1">Tampak</option>
								<option <?php echo ($tampak == null) ? ("") : (($tampak == 0) ? ("selected") : ("")); ?> value="0">Tidak Tampak</option>
							</select>
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<div class="col-lg-offset-3 col-lg-9">
							<button type="submit" class="btn btn-info">Simpan</button>
							<button type="button" onClick="kembali()" class="btn btn-default">Kembali</button>
						</div>
					</div><!-- End .form-group  -->

				</form>

			</div>
		</div>
	</div>

</div><!-- End .panel -->
<script language="javascript">
	function kembali(){
		document.location="<?php echo site_url("master_pertanyaan"); ?>";
	}
	var	sum = <?php echo ($jawaban2 == null) ? ("1") : (($jawaban3 == null) ? ("2") : (($jawaban4 == null) ? ("3") : ("4"))); ?>;
	function tambah(divName){
		sum++;
		if(sum < 5){
			var newdiv	= document.createElement("input");
			newdiv.type	= "text";
			newdiv.name="jawaban"+sum;
			newdiv.className= "form-control";
			document.getElementById(divName).appendChild(newdiv);
		} else {
			alert("Inputan jawaban maksimal hanya 4 !");
		}
	}
</script>